home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-06 | 2.7 KB | 139 lines | [TEXT/MSET] |
-
- \ A tescrollV is a textbox with a vertical scrollbar
-
- :class textvScroll super{ vscrollBar }
-
- \ ScrollOnce: is a late-bound call in the superclass, so this is all we need
-
- :m ScrollOnce:
- 0 ( dh)
- get: controlWas get: self - get: pixDelta * ( dv)
- pack
- handle: [ get: scrollObject ] \ will be the TEHandle, of course
- call TEPinScroll
- get: self put: controlWas
- ;m
-
- ;class
-
-
- :class tescrollV super{ tebox nullSelect OwnerObj }
- textvScroll tvscroll
-
- :m classinit:
- 10 put: #chars \ #characters per line
- 5 put: #lines \ #lines to display
- ;m
-
- \ CalcVScrollValue: is useful for calculating the new value of a vertical scrollbar
- \ in a scrolling TErecord after the toolbox has automatically scrolled the
- \ text for us (it is then up to us to figure out the new scrollbar settings).
-
- :m CalcVScrollValue: ( -- n )
- ptr: super 8 + ( dest) gettopy: rect
- ptr: super ( view) gettopy: rect -
- lineHeight: super / ;m
-
-
- \ (new): must only be done at new: time since we are storing an ivar address
- \ in our scrollbar !!
- :m (new):
- view: super { l t r b -- }
- r ( x) t 1- ( y) b t - 2 + ( len ) init: tvscroll \ note, storing addr of tescrollV in control!
-
- lineheight: super ( pixdelta to scroll) \ te, must be new:
- get: #lines 1- ( number of lines for a page scroll)
- setscrollValues: tvscroll \ should use font info for this instead?
- 0 0 putrange: tvscroll \ we are assuming there is no text at new time
-
- l t r b setscrollrect: tvscroll
- ;m
-
- :m new: { wptr -- }
- wptr new: super \ here, view and dest will be set same as outline
- (new): self \ must only be done at new: time
- true makeint handle: super call TEAutoView \ enable automatic scrolling
- wptr new: tvscroll
- self scrolledBy: tvscroll
- ;m
-
- :m activate:
- activate: super
- activate: tvscroll ;m
-
- :m deactivate:
- deactivate: super
- deactivate: tvscroll ;m
-
- :m move: { dx dy -- }
- dx dy move: super
- dx dy move: tvscroll ;m
-
- :m moveto: { x y -- }
- x y moveto: super
- x y moveto: tvscroll ;m
-
- :m release:
- release: super
- release: tvscroll
- ;m
-
- :m hit?: ( -- b )
- view: super put: temprect 16 0 stretch: temprect
- where: theMouse
- temprect PtinRect
- ;m
-
- :m setControl:
- 0 ( min) #lines: super ( max)
- get: #lines - 0 max
- putrange: tvscroll
- CalcVScrollValue: self set: tvscroll
- draw: tvscroll
- ;m
-
- :m click:
- hit?: tvscroll
- IF click: tvscroll
- setControl: [self] exit
- THEN
- hit?: super
- IF click: super
- setControl: [self]
- THEN
- ;m
-
- :m key:
- key: super
- setControl: [self]
- ;m
-
- :m draw:
- draw: super
- draw: tvscroll
- ;m
-
- :m cut:
- cut: super setControl: [self] ;m
-
- :m paste:
- paste: super setControl: [self] ;m
-
- :m clear:
- clear: super setControl: [self] ;m
-
- :m put: ( addr len -- )
- put: super setControl: [self] ;m
-
- ;class
-
- endload
-
- *** EXAMPLE USE
-
- selwindow w
- test: w
-
- tescrollV tv
- tv add: w
-